package com.dys.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: 疾风
 * @ClassName: Servlet02
 * @Description: 请求与转发(目标组件)
 * @CreateDate: 2024/09/20
 * @Version: v1.0.0
 */
@WebServlet(urlPatterns = "/servlet02.do")
public class Servlet02 extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行Servlet02的service方法......");
        // 接收Servlet01传递过来的参数
        String money = req.getParameter("money");
        System.out.println("Servlet01转发过来的money：" + money);

        // 做出响应：会清除上一个做出的任何响应数据
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().write("支付宝到账：" + money + "元");
    }
}
